package me.ianhe.springboot_vue.dao;

import me.ianhe.springboot_vue.entities.Persons;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import java.util.List;

/**
 * @author iHelin
 * @since 2017/11/8 10:51
 */
public interface PersonsRepository extends JpaRepository<Persons, Long> {

    String FIND_SEX = "select DISTINCT sex from Persons p";

    @Query(FIND_SEX)
    List<Persons> findSex();

    Page<Persons> findBySexAndEmailContains(String sexName, String emailName, Pageable pageable);

    Page<Persons> findBySex(String sexName, Pageable pageable);

    Persons findById(Long id);

}
